<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateShoppingCartsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('shopping_carts', function (Blueprint $table) {
            $table->integer('member_id')->unsigned()->comment('会员（采购商） ID');
            $table->integer('goods_id')->unsigned()->comment('商品 ID');
            $table->integer('amount')->unsigned()->comment('数量');
            $table->integer('goods_spec_id')->unsigned()->nullable()->comment('商品规格 ID，若该商品不包含规格，则为 NULL');
            $table->string('message')->comment('留言');

            $table->primary(['member_id', 'goods_id']);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('shopping_carts');
    }
}
